import * as order from "../../api/order";

Page({
    data: {
        item:{},
        refundStatusDesc:"",
        afterSaleTypeDesc:"",
        refundReasonDesc:"",
        skuReturnNum:"",
        refundRemark:"",
        refundAmount:""
    },
    onLoad(options){
        order.afterSaleProcessQuery({
            orderNo: options.orderNo
        })
        .then((res)=>{
            this.setData({
                refundStatusDesc:res.refundStatusDesc,
                ['item.orderNo']:res.orderNo,
                ['item.orderListNewDetailVo']:res.afterSaleDetailSkuVoList,
                afterSaleTypeDesc:res.afterSaleTypeDesc,
                refundReasonDesc:res.refundReasonDesc,
                skuReturnNum:res.skuReturnNum,
                refundRemark:res.refundRemark,
                refundAmount:res.refundAmount
            })
        })
    },
    get_order_list(){

        let createTime =  this.data.createTime.length == 0 ? '' : this.data.createTime.join(",");

        order.getOrderList({
            currentPage:this.data.currentPage,
            pageSize:10,
            createTime:createTime,
            keyword:this.data.keyword,
            orderStatus:this.data.orderStatus
        })
        .then((res)=>{
            this.setData({
                item:res.list[0].orderListNewDetailVo[0]
            })
        })
    },
    handle_sum_num(e){

        let { value } = e.currentTarget.dataset;

        if( value == -1 && this.data.skuNum == 1 ){
            return;
        }

        this.setData({
            skuNum: this.data.skuNum + value
        });
        
    },
    get_input_value(e){
        this.setData({
            content:e.detail.value
        })
    },
    confirm_sales_way(e){
        this.setData({
            salesWayIndex:e.detail.value,
            salesWayOpen:false
        })
    },
    confirm_sales_reason(e){
        this.setData({
            salesReasonIndex:e.detail.value,
            salesReasonOpen:false
        })
    },
    open_sales_way(){
        this.setData({
            salesWayOpen:true
        })
    },
    open_sales_reason(){
        this.setData({
            salesReasonOpen:true
        })
    },
    cancel_all_box(){
        this.setData({
            salesWayOpen:false,
            salesReasonOpen:false,
        })
    }
})
